package queue;

import linkedList.CandyLinkedList_v4;

public class CandyLinkedListQueue<E> implements CandyQueue<E> {
	private CandyLinkedList_v4<E> list;
	
	public CandyLinkedListQueue() {
		this.list = new CandyLinkedList_v4();
	}

	@Override
	public int getSize() {
		return list.getSize();
	}

	@Override
	public boolean isEmpty() {
		return list.isEmpty();
	}

	@Override
	public void enqueue(E e) {
		list.addLast(e);
	}

	@Override
	public E dequeue() {
		return list.removeFirst();
	}

	@Override
	public E getFront() {
		return list.getFirst();
	}

	@Override
	public int getCapacity() {
		return list.getSize();
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder("CandyLinkedListQueue front [ ");
		return sb.append(list + " ] rear").toString();
	}
	
	public static void main(String[] args) {
		CandyLinkedListQueue<Integer> queue = new CandyLinkedListQueue<>();
		for(int i = 0; i < 10; i++) {
			queue.enqueue(i);
			System.out.println(queue);
		}
		System.out.println(queue.dequeue());
		System.out.println(queue);
	}
}
